{include file='public/new_header'}
</head>
<body>
    <!-- 最顶部 -->
    <div class="head">
        <img src="__STATIC__/new/image/left-correct.png" alt="" class="back">
        <div class="top">
            <span>收货地址</span>
        </div>
    </div>
    <!-- 内容部分 -->
    <div class="content">
        {volist name='list' id='vo'}
        <div class="address-one">
            <div class="ads-top">
                <span>{$vo.name}</span>
                <span>{$vo.tel}</span>
            </div>
            <div class="ads-cont">
                <span>{$vo.sca_name} {$vo.address}</span>
                <p class="asct"></p>
            </div>
            <div class="ads-ft">
                <div class="choose" onclick="f1(this,'{$vo.id}','{$vo.is_default}')">
                    <img src="__STATIC__/new/image/correct.png" alt="" class="cose" style='display:{eq name="vo.is_default" value="1"}block{else/}none{/eq}'>
                </div>
                <div class="adft">
                    <p><a href="{:url('save_address', ['id'=>$vo['id']])}" >编辑</a></p>
                    <p onclick="delCon(this, {$vo['id']})">删除</p>
                </div>
            </div>
        </div>
        {/volist}

    </div>
    <!-- 添加收货地址 -->
    <div class="foot">
        <div class="foot-r">
            <img src="__STATIC__/new/image/add.png" alt="">
            <span><a href="{:url('save_address', ['id'=>$vo['id']])}" >添加收货地址</a></span>
        </div>
    </div>
</body>

</html>
<script type="text/javascript">
    var laytpl, layer;
		layui.use(['laytpl', 'layer'], function () {
        });
    var sum=1
    function f1(obj,id,is_default){
        if(is_default!=1){
            $.post("{:url('setDefault')}", {id:id}, function(data){
                location.reload();
            }, 'json');
        }else{
            return false;
        }
        
        
        
    }
    function delCon(self, id) {
        layer.confirm("您确定要删除该地址吗？", function(){
            $.post( "{:url('delAddress')}" , {id:id}, function ( data ) {
                if (data.status == 'y') {
                    layer.msg(data.info);
                    $(self).parents('.address-one').remove();
                } else {
                    layer.msg(data.info);
                }
            }, "json");
        });
    }
</script>